package org.sanmao.wyj.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.sanmao.wyj.dao.CashoutDao;
import org.sanmao.wyj.domain.Cashout;
import org.sanmao.wyj.service.CashoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CashoutServiceImpl extends ServiceImpl<CashoutDao, Cashout> implements CashoutService {
    @Autowired
    private CashoutDao cashoutDao;

    @Override
    public IPage<Cashout> findCashoutList(int currentPage, int pageSize,int state) {
        IPage<Cashout> page = new Page<>(currentPage,pageSize);
        return cashoutDao.findCashoutList(page,state);
    }

    @Override
    public Boolean doCashoutByid(int id) {
        Cashout cashout = cashoutDao.selectById(id);
        cashout.setState(2);
        UpdateWrapper<Cashout> wrapper = new UpdateWrapper<>();
        wrapper.eq("cashout_order_id",id);
        return cashoutDao.update(cashout,wrapper)>0;

    }
}
